home *** CD-ROM | disk | FTP | other *** search
/ Aminet 1 / Aminet - June 1993 [Walnut Creek].iso / usenet / sources / volume91 / utilitys / butonask / part01
Encoding:
Internet Message Format  |  1991-03-04  |  9.2 KB

  1. Path: news.larc.nasa.gov!amiga-request
  2. From: amiga-request@ab20.larc.nasa.gov (Amiga Sources/Binaries Moderator)
  3. Subject: v91i043: Buttonask - replacement for AmigaDOS ASK command, Part01/01
  4. Reply-To: simpsonc@project4.computer-science.manchester.ac.uk
  5. Newsgroups: comp.sources.amiga
  6. Message-ID: <comp.sources.amiga:v91i043@ab20.larc.nasa.gov>
  7. Date: 03 Mar 91 23:21:00 GMT
  8. Approved: tadguy@uunet.UU.NET (Tad Guy)
  9. X-Mail-Submissions-To: amiga@uunet.uu.net
  10. X-Post-Discussions-To: comp.sys.amiga.misc
  11.  
  12. Submitted-by: simpsonc@project4.computer-science.manchester.ac.uk
  13. Posting-number: Volume 91, Issue 043
  14. Archive-name: utilities/buttonask/part01
  15.  
  16. [ includes uuencoded executables  ...tad ]
  17.  
  18. BUTTONASK
  19. ---------
  20.  
  21.   ButtonAsk is a replacement for the AmigaDOS ASK command. It takes a prompt
  22. string from the command line, echos it to standard output, and waits for
  23. either the left or right mouse button to be pressed. The program will then
  24. send a return code of either 5(WARN) or 0 to the system which can be
  25. interpreted by using the IF command. This program is mainly used in scripts.
  26.  
  27. WAITBUTTONS
  28. -----------
  29.  
  30.   This is a small program which is used to detect when no mouse buttons are
  31. down. If you intend to use buttonask more than once in the same script then
  32. you should use this command to check that a button is not already down 
  33. before calling buttonask.
  34.  
  35. #!/bin/sh
  36. # This is a shell archive.  Remove anything before this line, then unpack
  37. # it by saving it into a file and typing "sh file".  To overwrite existing
  38. # files, type "sh file -c".  You can also feed this as standard input via
  39. # unshar, or by typing "sh <file", e.g..  If this archive is complete, you
  40. # will see the following message at the end:
  41. #        "End of archive 1 (of 1)."
  42. # Contents:  ButtonAsk.s ButtonAsk.uu ReadMe WaitButtons.s
  43. #   WaitButtons.uu
  44. # Wrapped by tadguy@ab20 on Sun Mar  3 18:20:57 1991
  45. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  46. if test -f 'ButtonAsk.s' -a "${1}" != "-c" ; then 
  47.   echo shar: Will not clobber existing file \"'ButtonAsk.s'\"
  48. else
  49. echo shar: Extracting \"'ButtonAsk.s'\" \(2579 characters\)
  50. sed "s/^X//" >'ButtonAsk.s' <<'END_OF_FILE'
  51. X**************************************
  52. X*                                    *
  53. X*           ButtonAsk v1.0           *
  54. X*                                    *
  55. X*        (c) 1990 Chris Simpson      *
  56. X*                                    *
  57. X* USAGE: ButtonAsk <prompt>          *
  58. X*                                    *
  59. X* This program is a replacement for  *
  60. X* the AmigaDOS ASK command except    *
  61. X* that the mouse buttons are used    *
  62. X* rather than entering 'y' or 'n'    *
  63. X* For this program to work, some     *
  64. X* text for the prompt must be given  *
  65. X* in the command line. This text is  *
  66. X* echoed to stdout and then a mouse  *
  67. X* button is waited for. Pressing the *
  68. X* left button returns a return code  *
  69. X* of 5(WARN) and pressing the right  *
  70. X* button returns a return code of 0. *
  71. X*                                    *
  72. X**************************************
  73. X
  74. X        SECTION ButtonAsk,code_c    ; Put into chip ram
  75. X
  76. X        INCDIR    include:        ; Read include files
  77. X        INCLUDE    exec/exec_lib.i
  78. X        INCLUDE libraries/dos_lib.i
  79. X
  80. XLeftReg        equ    $bfe001            ; Set up button registers
  81. XRightReg    equ    $dff016
  82. X
  83. X        move.l    d0,Length        ; Store length of CLI line
  84. X        move.l    a0,Address        ; Store address of CLI line
  85. X
  86. X        move.l    #100,ReturnCode        ; Default return code
  87. X
  88. X        lea    DOSName,a1        ; Try to open dos library
  89. X        clr.l    d0
  90. X        CALLEXEC OpenLibrary
  91. X        tst.l    d0            ; Quit if not opened
  92. X        beq    Error
  93. X        move.l    d0,_DOSBase        ; Else store dos base
  94. X
  95. X        CALLDOS    Output            ; Find standard output
  96. X        move.l    d0,OutHandle        ; Store handle address
  97. X
  98. X        move.l    Length,d0        ; Get back length
  99. X        move.l    Address,a0        ; Get back address
  100. X
  101. X        cmp.l    #1,Length        ; Make sure not just linefeed
  102. X        bgt    GotPrompt
  103. X
  104. X        move.l    OutHandle,d1        ; Write USAGE text
  105. X        move.l    #Usage,d2
  106. X        move.l    #UsageEnd-Usage,d3
  107. X        CALLDOS Write
  108. X        bra    CloseDOS
  109. X
  110. X        
  111. XGotPrompt    move.l    OutHandle,d1        ; Write the prompt out
  112. X        move.l    a0,d2
  113. X        move.l    d0,d3        
  114. X        CALLDOS Write
  115. X
  116. XWaitForButton      btst    #6,$bfe001
  117. X        beq    LeftPressed
  118. X
  119. X        btst    #10,$dff016
  120. X        beq    RightPressed
  121. X
  122. X        bra    WaitForButton
  123. X
  124. XLeftPressed    move.l    #5,ReturnCode
  125. X        bra    CloseDOS
  126. X
  127. XRightPressed    move.l    #0,ReturnCode
  128. X        
  129. XCloseDOS    move.l    _DOSBase,a1        ; Close dos library
  130. X        CALLEXEC CloseLibrary
  131. X
  132. X        move.l    ReturnCode,d0        ; Exit with return code
  133. XError        rts
  134. X
  135. X*** Data ***
  136. X
  137. XDOSName        dc.b    "dos.library",0
  138. X        even
  139. X_DOSBase    dc.l    0
  140. X
  141. XOutHandle    dc.l    0
  142. X
  143. XUsage        dc.b     "ButtonAsk v1.0   (c) 1990 Chris Simpson",13,10,13,10
  144. X        dc.b    "USAGE: ButtonAsk <prompt>",13,10,13,10
  145. X        dc.b    "Return code will be ... 5 if left button pressed",13,10
  146. X        dc.b    "                        0 if right button pressed",13,10,0
  147. XUsageEnd    even
  148. X
  149. XAddress        dc.l    0
  150. XLength        dc.l    0
  151. X
  152. XReturnCode    dc.l    0
  153. X
  154. END_OF_FILE
  155. if test 2579 -ne `wc -c <'ButtonAsk.s'`; then
  156.     echo shar: \"'ButtonAsk.s'\" unpacked with wrong size!
  157. fi
  158. # end of 'ButtonAsk.s'
  159. fi
  160. if test -f 'ButtonAsk.uu' -a "${1}" != "-c" ; then 
  161.   echo shar: Will not clobber existing file \"'ButtonAsk.uu'\"
  162. else
  163. echo shar: Extracting \"'ButtonAsk.uu'\" \(811 characters\)
  164. sed "s/^X//" >'ButtonAsk.uu' <<'END_OF_FILE'
  165. Xbegin 644 ButtonAsk
  166. XM```#\P`````````!``````````!```!J0``#Z0```&HCP````9XCR````9HCB
  167. XM_````&0```&B0_D```#:0H`L>``$3J[]V$J`9P``KB/`````YBQY````YDZN#
  168. XM_\0CP````.H@.0```9X@>0```9H,N0````$```&>;@``(B(Y````ZB0\````6
  169. XM[B8\````K"QY````YDZN_]!@``!*(CD```#J)`@F`"QY````YDZN_]`(.0`&P
  170. XM`+_@`6<``!((.0`*`-_P%F<``!1@`/_F(_P````%```!HF````PC_```````;
  171. XM``&B(GD```#F+'@`!$ZN_F(@.0```:).=61O<RYL:6)R87)Y````````````0
  172. XM0G5T=&]N07-K('8Q+C`@(""I(#$Y.3`@0VAR:7,@4VEM<'-O;@T*#0I54T%'\
  173. XM13H@0G5T=&]N07-K(#QP<F]M<'0^#0H-"E)E='5R;B!C;V1E('=I;&P@8F4@^
  174. XM+BXN(#4@:68@;&5F="!B=71T;VX@<')E<W-E9`T*("`@("`@("`@("`@("`@B
  175. XM("`@("`@("`@,"!I9B!R:6=H="!B=71T;VX@<')E<W-E9`T*````````````F
  176. XM```````````#[````!,``````````@````@````2````&````"X````T````8
  177. XM/@```$0```!*````5````%X```!D````<````'X```"(````L@```,````#&0
  178. X,````U`````````/R)
  179. X``
  180. Xend
  181. Xsize 552
  182. END_OF_FILE
  183. if test 811 -ne `wc -c <'ButtonAsk.uu'`; then
  184.     echo shar: \"'ButtonAsk.uu'\" unpacked with wrong size!
  185. fi
  186. # end of 'ButtonAsk.uu'
  187. fi
  188. if test -f 'ReadMe' -a "${1}" != "-c" ; then 
  189.   echo shar: Will not clobber existing file \"'ReadMe'\"
  190. else
  191. echo shar: Extracting \"'ReadMe'\" \(1175 characters\)
  192. sed "s/^X//" >'ReadMe' <<'END_OF_FILE'
  193. XBUTTONASK
  194. X---------
  195. X
  196. X  ButtonAsk is a replacement for the AmigaDOS ASK command. It takes a prompt
  197. Xstring from the command line, echos it to standard output, and waits for
  198. Xeither the left or right mouse button to be pressed. The program will then
  199. Xsend a return code of either 5(WARN) or 0 to the system which can be
  200. Xinterpreted by using the IF command. This program is mainly used in scripts.
  201. X
  202. XEXAMPLE:
  203. X
  204. X    BUTTONASK Press a mouse button
  205. X    IF WARN
  206. X      ECHO "Hello"
  207. X    ELSE
  208. X      ECHO "GoodBye"
  209. X    ENDIF
  210. X
  211. X   This script will print out the message "Press a mouse button", and then
  212. Xwait for mouse button to be pressed. Then either the Hello or GoodBye 
  213. Xmessage will be output depending which button was pressed. See the source
  214. Xfile for more details
  215. X
  216. XWAITBUTTONS
  217. X-----------
  218. X
  219. X  This is a small program which is used to detect when no mouse buttons are
  220. Xdown. If you intend to use buttonask more than once in the same script then
  221. Xyou should use this command to check that a button is not already down 
  222. Xbefore calling buttonask.
  223. X
  224. XDISTRIBUTION:
  225. X
  226. X  ButtonAsk is copyright 1990 Chris Simpson but may be distributed in any
  227. Xway as long as this file, WaitButtons, and both source files are included.
  228. END_OF_FILE
  229. if test 1175 -ne `wc -c <'ReadMe'`; then
  230.     echo shar: \"'ReadMe'\" unpacked with wrong size!
  231. fi
  232. # end of 'ReadMe'
  233. fi
  234. if test -f 'WaitButtons.s' -a "${1}" != "-c" ; then 
  235.   echo shar: Will not clobber existing file \"'WaitButtons.s'\"
  236. else
  237. echo shar: Extracting \"'WaitButtons.s'\" \(172 characters\)
  238. sed "s/^X//" >'WaitButtons.s' <<'END_OF_FILE'
  239. XLeftReg        equ    $bfe001            ; Set up button registers
  240. XRightReg    equ    $dff016
  241. X
  242. XWaitForButton      btst    #6,$bfe001
  243. X        beq    WaitForButton
  244. X
  245. X        btst    #10,$dff016
  246. X        beq    WaitForButton
  247. X
  248. X        rts
  249. X
  250. X
  251. END_OF_FILE
  252. if test 172 -ne `wc -c <'WaitButtons.s'`; then
  253.     echo shar: \"'WaitButtons.s'\" unpacked with wrong size!
  254. fi
  255. # end of 'WaitButtons.s'
  256. fi
  257. if test -f 'WaitButtons.uu' -a "${1}" != "-c" ; then 
  258.   echo shar: Will not clobber existing file \"'WaitButtons.uu'\"
  259. else
  260. echo shar: Extracting \"'WaitButtons.uu'\" \(131 characters\)
  261. sed "s/^X//" >'WaitButtons.uu' <<'END_OF_FILE'
  262. Xbegin 644 WaitButtons
  263. XM```#\P`````````!```````````````'```#Z0````<(.0`&`+_@`6<`__8(\
  264. X3.0`*`-_P%F<`_^I.=0`````#\@``P
  265. X``
  266. Xend
  267. Xsize 64
  268. END_OF_FILE
  269. if test 131 -ne `wc -c <'WaitButtons.uu'`; then
  270.     echo shar: \"'WaitButtons.uu'\" unpacked with wrong size!
  271. fi
  272. # end of 'WaitButtons.uu'
  273. fi
  274. echo shar: End of archive 1 \(of 1\).
  275. cp /dev/null ark1isdone
  276. MISSING=""
  277. for I in 1 ; do
  278.     if test ! -f ark${I}isdone ; then
  279.     MISSING="${MISSING} ${I}"
  280.     fi
  281. done
  282. if test "${MISSING}" = "" ; then
  283.     echo You have the archive.
  284.     rm -f ark[1-9]isdone
  285. else
  286.     echo You still need to unpack the following archives:
  287.     echo "        " ${MISSING}
  288. fi
  289. ##  End of shell archive.
  290. exit 0
  291. -- 
  292. Mail submissions (sources or binaries) to <amiga@uunet.uu.net>.
  293. Mail comments to the moderator at <amiga-request@uunet.uu.net>.
  294. Post requests for sources, and general discussion to comp.sys.amiga.misc.
  295.